package org.koyad.portal.api;

import org.koyad.portal.context.PistonContext;
import org.koyad.portal.filters.PageUtils;
import org.koyad.portal.tags.ViewRoot;
import org.koyad.portal.tags.piston.PageFragmentTag;


public abstract class BaseAction {
	
	protected final String ERROR_PAGE = "/xml/error.xml";
	
	public abstract void execute();
	
	public void createView(String path) {
		PageFragmentTag fragment = (PageFragmentTag)PageUtils.getTree(path);
		ViewRoot viewRoot = PistonContext.getContext().getViewRoot();
		if(null != viewRoot.getCurrentTileId()) {
			viewRoot.addTileContent(fragment);
		} else {
			viewRoot.getCurrentTag().addChild(fragment);
			viewRoot.setCurrentTag(null);
		}
	}
	
}
